﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Messaging;

namespace ServiceController
{
    public delegate DataAccess.DataAccessResult GetDeploymentPropertyDelegate(String SubscriptionID,String CertificatePath,String ServiceName,String DeploymentSlot);

    public partial class ServiceController
    {
        GetDeploymentPropertyDelegate _GetDeploymentPropertyDelegate;

        

        public void GetDeploymentPropertyAsync(String SubscriptionID,String CertificatePath,String ServiceName,String DeploymentSlot, object UserState)
        {
            _GetDeploymentPropertyDelegate.BeginInvoke(SubscriptionID, CertificatePath,ServiceName, DeploymentSlot,
                new AsyncCallback(GetDeploymentPropertyCallBack), UserState);
        }

        void GetDeploymentPropertyCallBack(IAsyncResult ar)
        {
            AsyncResult aresult = (AsyncResult)ar;
            DataAccess.DataAccessResult result = _GetDeploymentPropertyDelegate.EndInvoke(ar);
            OnGetDeploymentPropertyComplete(new ServiceControllerEventArgs()
            {
                DeploymentProperty = result.DeploymentProperty,
                error = result.Error,
                UserState = ar.AsyncState,
                IsOperationSuccessful = result.IsOperationSuccessful,
            });
        }

        private DataAccess.DataAccessResult GetDeploymentProperty(String SubscriptionID,String CertificatePath,String ServiceName,String DeploymentSlot)
        {
            return da.GetDeploymentProperty(SubscriptionID, CertificatePath, ServiceName, DeploymentSlot);
        }
    }
}
